package gui.view.android.graphics;

import java.awt.Color;

import com.nightpiter.view.graphics.PointF;
import com.nightpiter.view.graphics.abstaractions.AbstractLinearGradient;

public class JavaLinearGradient extends JavaShader implements
		AbstractLinearGradient {

	private float positions[];
	private PointF from, to;
	private Color colors[];

	public JavaLinearGradient(float x0, float y0, float x1, float y1,
			int color0, int color1) {
		this.positions = new float[2];
		this.positions[0] = 0.0f;
		this.positions[1] = 1.0f;
		this.colors = new Color[2];
		this.colors[0] = new Color(color0, true);
		this.colors[1] = new Color(color1, true);
		this.from = new PointF(x0, y0);
		this.to = new PointF(x1, y1);
	}

	public JavaLinearGradient(float x0, float y0, float x1, float y1, int[] colors, float[] positions) {
		this.positions = new float[positions.length];
		for (int i = 0; i < positions.length; i++) {
			this.positions[i] = positions[i];
		}
		this.from = new PointF(x0, y0);
		this.to = new PointF(x1, y1);
		this.colors = new Color[colors.length];
		for (int i = 0; i < colors.length; i++) {
			this.colors[i] = new Color(colors[i], true);
		}
	}
	
	public Color getColorFrom() {
		return colors[0];
	}

	public Color getColorTo() {
		return colors[colors.length - 1];
	}

	public PointF getFrom() {
		return from;
	}

	public PointF getTo() {
		return to;
	}

}
